import serverService  from "../../service/server/serverService";
const koaRouter = require('koa-router');
const router = koaRouter();
// const decodetoken = require('../../config/decodetoken');    // 解密 token

/**
 * 上传批次
 **/
//查询批次列表
router.post('/getBatchList',async(ctx)=>{
    let result:any=await new serverService().getBatchList(ctx.request.body);
    if(result){
        ctx.body ={success:true,datas:result};
    }else{
        ctx.body ={success:false,msg:"未知错误"};
    }
})
//保存
router.post('/saveBatch',async(ctx)=>{
    let result:any=await new serverService().saveBatch(ctx.request.body);
    if(result){
        ctx.body ={success:true,datas:result};
    }else{
        ctx.body ={success:false,msg:"未知错误"};
    }
})
//删除
router.post('/delBatch',async(ctx)=>{
    let result:any=await new serverService().delBatch(ctx.request.body.id);
    if(result){
        ctx.body ={success:true,datas:result};
    }else{
        ctx.body ={success:false,msg:"未知错误"};
    }
})


/**
 * 数据查询
 **/
//数据列表
router.post('/getDataList',async(ctx)=>{
    let result:any=await new serverService().getDataList(ctx.request.body);
    if(result){
        ctx.body ={success:true,datas:result};
    }else{
        ctx.body ={success:false,msg:"未知错误"};
    }
})

//初始启动定时任务
// new serverService().startTask()

module.exports = router;